﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Smart.Admin.Api.Filters
{
    public class ResultFilterAttribute : Microsoft.AspNetCore.Mvc.Filters.ActionFilterAttribute
    {
        public override void OnResultExecuting(ResultExecutingContext context)
        {
            //// 获取原始的返回结果
            //var originalResult = context.Result;

            //// 检查原始结果是否为 OkObjectResult
            //if (originalResult is OkObjectResult okResult)
            //{
            //    // 获取原始数据
            //    var originalData = okResult.Value;

            //    // 修改数据
            //    var modifiedData = JsonConvert.SerializeObject(originalData);
            //    modifiedData = modifiedData.Replace("欢迎", "AAAA");



            //    // 创建新的 OkObjectResult
            //    var newResult = new OkObjectResult(modifiedData);

            //    // 替换原始结果
            //    context.Result = newResult; // 正确地替换结果
            //}

            //// 调用基类方法
            //base.OnResultExecuting(context);
        }
    }
}
